package com.javaee.my.dao;

import com.javaee.interceptor.entity.goods;
import com.javaee.interceptor.entity.user;
import com.javaee.interceptor.entity.userVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface userMapper {
    //通过姓名查询是否有这个人
    @Select("SELECT id FROM student WHERE username = #{username} and password=#{password}")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    int queryByUserNameAndPassword(user entityuser);
    //查询所有商品
    @Select("select * from goods")
    List<goods> queryAllgoods();
    @Insert("insert into shopping_cart (username,goods_id,nums,allprice)" +
            " values (username,goods_id,nums,allprice)")
    int addShopping_goods(@Param("username") String username,
                      @Param("goods_id") Integer goods_id,
                      @Param("nums") Integer nums,
                      @Param("allprice") float allprice);
    //添加用户
    @Insert("insert into student (username,password) values (#{username},#{password})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    user register(user user);
    //根据用户名查询账号信息
    @Select("select id from student where username=#{username}")
    int checkUserName(@Param("username")String username);

}
